<script>
function delete_video(id, title, url)
{
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		jQuery( "#dialog:ui-dialog" ).dialog( "destroy" );
		jQuery( "#dialog-title" ).html(title);	
		jQuery( "#dialog-modal" ).dialog({
			resizable: false,
			height:140,
			modal: true,			
			buttons: {
				"Yes": function() {
					loading_area('<%= image_tag "loading_ajax.gif" %>', "#videos-list", ".style1");
					$( this ).dialog( "close" );
					jQuery.ajax({
					  url: url,
					  type: 'DELETE',
					  success: function (data){
					    jQuery.ajax({
					      url: "<%= request.request_uri %>",
						  data: "format=js"
					    });
					  }
					});
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}

		});
}
function deleteAllVideos(id, title, url)
{
// alert(JSON.stringify(formToJSON('#mainForm')));

		if (!jQuery(articles .checkbox).is(:checked))
		{
			alert("Please select article/articles to delete");
			return false;
		}
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		jQuery( "#dialog:ui-dialog" ).dialog( "destroy" );
		jQuery( "#dialog-title" ).html("Delete all selected articles !!!");	
		jQuery( "#dialog-modal" ).dialog({
			resizable: false,
			height:140,
			modal: true,			
			buttons: {
				"Yes": function() {
					// loading_area('<%= image_tag "loading_ajax.gif" %>');
					$( this ).dialog( "close" );
					jQuery.ajax({
					  url: url,
					  type: 'DELETE',
					  success: function (data){
					    jQuery.ajax({
					      url: <%= url_for(:controller => 'videos',:action=>'delete_selected', :format => 'js') %>
					    });
					  }
					});
					jQuery( "#mainForm" ).submit();
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}

		});
		
}
function OnSubmitForm()
{
  if(document.pressed == 'Delete')
  {
   document.myform.action ="delete_selected";
  }
  //else
  //if(document.pressed == 'Update')
  //{
    //document.myform.action ="update.html";
  //}
  //return true;
}
</script>


<%= form_tag({:controller => 'videos', :action => 'delete_selected'}, :id => 'mainForm') do %>
	
						  <div class="dataTables_wrapper">
						  	
						    <div id="videos-list">
						      <table class="style1">

							<thead>
								<tr>
									<th><input type="checkbox" class="checkbox select-all" /></th>
									<th width="25%">Details</th>
									<th width="25%">Title</th>
									<th with ="25%">Status</th>
									<th width="15%" class="column_center">Controls</th>
									<th class="column_center">Published</th>
								</tr>
							</thead>
							
							<tbody>
                                                          <% @videos.each do |video| %>                                                            
                                                                <tr>
									<td><input type="checkbox" class="checkbox" name="ids[<%= video.id %>]" /></td>
									<td>
											<embed height="200" width="200" flashvars="file=/videos/<%=video.title%>&amp;displayheight=150&amp;width=150&amp;height=260&amp;backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x557722&amp;shuffle=false&amp;repeat=list" wmode="transparent" allowfullscreen="true" quality="high" name="playlist" id="playlist" style="" src="/Myplayer/player.swf" type="application/x-shockwave-flash"/> 
									</td>
									
									<td><a href="#"><%= link_to video.title, video %></a></td>
									<td> 
										<%= video.video_status.nil? ? 'no status' : video.video_status.name %>
									</td>									
									<td align="center">
                                                                          <%= link_to image_tag("ico_edit_16.png", :border=>0, :class => 'preview-but', :title => 'Edit'), edit_video_path(video) %>
                                                                          <span class="delete">
									    <td><%= link_to 'Delete', video, :confirm => 'Are you sure?', :method => :delete,:title=>'Delete' %></td>
									  </span>
                                                                          									  
									</td>
									<td align="center">
																		  
									</td>
								</tr>
                                                          <% end %>
                                                          </tbody>
						      </table>
						    </div>
						      
						<div class="tab-footer clear">
							<div class="tab-footer clear fl">
								<div class="fl">
									<!-- <select class="fl-space" name="action" id="action">
										<option value="option1">choose action...</option>	
										<option value="delete">Delete</option>
									</select> -->
									<input type="submit" class="button fl-space" id="submit1"  value="Delete" title="Delete selected item/items">
								</div>
						        </div>
								
						  <div class="dataTables_paginate paging_full_numbers">
                                                        <%= will_paginate(@events, :renderer => "PaginationListLinkRenderer") %>
						  </div>
                                                        <script type="text/javascript">
        
                                                          jQuery(document).ready(function() {
                                                            jQuery('.pagination a').attr('data-remote', 'true');
                                                            jQuery('.pagination a').attr('update', 'dd');
							    jQuery('.pagination a').click(function() {
										      loading_area('<%= image_tag "loading_ajax.gif" %>', "#events-list", ".style1");
										    });
							    jQuery('#events .checkbox.select-all').click(function() {
										      //alert(jQuery('#articles .checkbox.select-all').is(':checked'));
										      jQuery("#events .checkbox").attr("checked", jQuery('#events .checkbox.select-all').is(':checked'));										      
										    });
							    
							    jQuery('.published').click(function() {
										      //alert(jQuery('#articles .checkbox.select-all').is(':checked'));
										      //jQuery('.published').html('<div class="loading"><%= image_tag "loading_ajax.gif" %></div>');
										      this.innerHTML = '<div class="published_loading"><%= image_tag "published_ajax.gif" %></div>';
										    });
							    
                                                          });
        
                                                        </script>							
						</div>
						  </div>

<% end %>